package net.servir.diagnostico.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import net.servir.diagnostico.model.IdentificacionParticipante;
import net.servir.diagnostico.model.Test;
import net.servir.diagnostico.service.DiagnosticoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class FueraPlazoPruebaController {

	@Autowired
	private DiagnosticoService diagnosticoService;
	
	@RequestMapping("/fueraPlazoPrueba.htm")	
	public @ModelAttribute("test")
	Test  fueraPlazoPrueba(HttpServletRequest request) {
		
		HttpSession sesion = request.getSession();
		
		Test obj = null;
		int codTest = 0;
		if (sesion.getAttribute("participante")!=null)
		{			
			IdentificacionParticipante identParticipante =(IdentificacionParticipante)sesion.getAttribute("participante"); 
			Number idTest = identParticipante.getId_test();
			obj = diagnosticoService.obtenerTest(idTest);
		}
		return obj;
	}
	
}
